#pragma once
#include "Game/Process/RenderProcess.h"
#include "Render/Tradition/ComputePipeline.h"
#include "Render/Shader/RHIDescriptor.h"
#include "Render/Tradition/RHIFramebuffer.h"
#include "LocalEntity.h"
#include "LocalShader.h"

class LocalScene;
class VoxelProcess;

class OctreeProcess : public RenderProcess
{
	DECLARE_PROCESS(OctreeProcess)

	struct PushConstants
	{
		uint32 fragmentNum;
		uint32 voxelResolution;
	};

public:

	PushConstants mPushConstants;

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

protected:

	uint32 GroupX64(uint32 value);

protected:

	LocalScene* mLocalScene;

	VoxelProcess* mVoxelProcess;

	uint32 mMinOctreeNodeNum;

	uint32 mMaxOctreeNodeNum;





	RefCountPtr<RHIBuffer> mCounterBuffer;

	RefCountPtr<RHIBuffer> mBuildInfoBuffer;

	RefCountPtr<RHIBuffer> mIndirectBuffer;

	RefCountPtr<RHIBuffer> mOctreeBuffer;







	RefCountPtr<RHIDescriptor> mOctreeAllocNodeDescriptor;

	DescriptorMask mOctreeAllocNodeDescriptorMask;

	RefCountPtr<ComputePipeline> mOctreeAllocNodePipeline;






	RefCountPtr<RHIDescriptor> mOctreeInitNodeDescriptor;

	DescriptorMask mOctreeInitNodeDescriptorMask;

	RefCountPtr<ComputePipeline> mOctreeInitNodePipeline;






	RefCountPtr<RHIDescriptor> mOctreeTagNodeDescriptor;

	DescriptorMask mOctreeTagNodeDescriptorMask;

	RefCountPtr<ComputePipeline> mOctreeTagNodePipeline;






	RefCountPtr<RHIDescriptor> mOctreeModifyArgDescriptor;

	DescriptorMask mOctreeModifyArgDescriptorMask;

	RefCountPtr<ComputePipeline> mOctreeModifyArgPipeline;








	RefCountPtr<RHICommandBuffer> mCommandBuffer;

	RefCountPtr<RHIFence> mFence;

};
